﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web.Mvc;
using ClientSite2nd.CurrenciesService;

namespace ClientSite2nd.Models
{
    public class Companies
    {
        public static List<SelectListItem> All
        {
            get
            {
                CurrencyWCFServiceClient proxy = new CurrencyWCFServiceClient();
                List<SelectListItem> companies = new List<SelectListItem>();
                
                foreach (DataRow row in proxy.GetCompaniesList().Rows)
                {
                    SelectListItem company = new SelectListItem();
                    company.Value = (string)row["CompanyName"];
                    company.Text = (string)row["CompanyName"];
                    companies.Add(company);
                }
                companies.Sort((a, b) => String.Compare(a.Text, b.Text));
                return companies;
            }
        }

    }
}